import nibabel as nib
import numpy as np

def read_nifti_image(image_path, crop: bool = False) -> np.array:
    """
    NOT USED RIGHT NOW
    Reads nifti image and takes every third time step. Takes Middle short axis slice
    """
    img = nib.load(image_path)
    data = img.get_fdata(dtype=np.float32)
    
    mid_slice_index = data.shape[2] // 2
    
    middle_slice = data[:, :, mid_slice_index, :]

    if crop:
        middle_slice = middle_slice[:, :, ::3]

    middle_slice = middle_slice.astype(np.float32)
    
    middle_slice = np.transpose(middle_slice, axes=(2, 0, 1))

    return middle_slice
